/*
 * Copyright 2020-2025 the original author or authors.
 * You cannot use this file unless authorized by the author.
 */
package org.ipig.query;

import org.ipig.proc.helper.ProcHelper;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * QuerySo
 *
 * @author <a href="mailto:comchnts@163.com">chinats</a>
 * @version $$Id: QuerySo.java 3 2020-01-21 09:36:33Z ts <comchnts@163.com> $$
 * @since 1.0
 */
@Data
@ToString
@NoArgsConstructor
@AllArgsConstructor
public class QuerySo implements Serializable {
    /**
     * 业务
     */
    private String biz;
    /**
     * 业务维度
     */
    private String dim;
    /**
     * 查询key[某维度下的查询主键]
     */
    private String key;
    //过期
    //private Boolean exp;
    /**
     * 查询条件[某维度下的查询主键下的所有查询条件]
     */
    private List<QueryVar> vars = new ArrayList<>();

    public QuerySo setBiz(String biz) {
        this.biz = biz;
        return this;
    }

    public QuerySo setDim(String dim) {
        this.dim = dim;
        return this;
    }

    public QuerySo setKey(String key) {
        this.key = key;
        return this;
    }

    public String getCachedKey() {
        return ProcHelper.getCachedKey(biz, dim, key);
    }
}
